package 作业;
import java.util.Scanner;
public class workzuoye {
    public static void main(String[] args) {
        /*
        Scanner scan=new Scanner(System.in);
        int num=(int) (Math.random()*100);
        while (true){
            System.out.println("开始猜吧");
            int guess= scan.nextInt();
            System.out.println(num);
            if (guess>num){
                System.out.println("da");
            }
            else if (guess<num){
                System.out.println("xiao");
            }
            else {
                System.out.println("dui");
                break;
            }

        }

         */


/*
    public static String generateVeriCode(int len){
        String code ="";
        char[]chs={'a','b','c','d','e','f','g','h','i','j'
                , 'k','l','m','n','o','p','q','r','s','t'
                ,'u','v','w','x','y','z','A','B','C','D','E'
                ,'F','G','H','I','J','K','L','M','N','O','P'
                ,'Q','R','S','T','U','V','W','X','Y','Z'
                ,'1','2','3','4','5','6','7','8','9'};
        for (int i=1;i<=len;i++){
            int index=(int)(Math.random()*chs.length);
            code +=chs[index];
        }
        return code;
    }

 */
        /*
        for (int num=2;num<=100;num++){
            boolean flag=true;
            for (int i=2;i<=num;i++){
                if (num%i==0){
                    flag=false;
                    break;
                }
            }
            if (flag){
                System.out.println(num+"\t");
            }
        }

         */
/*
        Scanner scan=new Scanner(System.in);
        System.out.println("机票价格");
        double price= scan.nextDouble();
        System.out.println("月份");
        int month= scan.nextInt();
        System.out.println("舱位：1.头等 2.商务 3.经济");
        int type= scan.nextInt();
        double finalPrice=calAirPrice(price,month,type);
        if(finalPrice!=-1){
            System.out.println("机票最后价格："+finalPrice);
        }
    }
    public static double calAirPrice(double price,int month,int type){

        double finalPrice=0.0;
        if (month<1||month>12){
            System.out.println("月份输入错误");
            return -1;

        }
        if (type<1||type>3){
            System.out.println("舱位输出错误");
            return -1;
        }
        if (month>=5&&month<=10){
            switch (type){
                case 1:
                    finalPrice=price*0.9;
                    break;
                case 2:
                    finalPrice=price*0.85;
                    break;
                case 3:
                    finalPrice=price*0.8;
                    break;
            }

        }else {
            switch (type){
                case 1:
                    finalPrice=price*0.7;
                    break;
                case 2:
                    finalPrice=price*0.65;
                    break;
                case 3:
                    finalPrice=price*0.6;
                    break;
            }
        }
        return finalPrice;

 */
        double[] scores = enterData();
        double avg = calAvg(scores);
        System.out.println("平均分为:"+avg);
    }


    public static double[] enterData(){
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[6];
        for(int i=0;i<scores.length;i++){
            System.out.println("请录入第"+(i+1)+"个评委的分数:");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }


    public static double calAvg(double[] scores){
        double total = calTotal(scores);
        double avg = total/(scores.length-2);
        return avg;
    }


    public static double calTotal(double[] scores){
        double total = 0.0;
        double max = scores[0];
        double min = scores[0];
        for(int i=0;i<scores.length;i++){
            if(scores[i]>max){
                max=scores[i];
            }
            if(scores[i]<min){
                min=scores[i];
            }
            total += scores[i];
        }
        return total-max-min;
    }
}






